
#pragma once
//#include "clientNetInterface.h"
// #include "WinMFCSystem.h"




#define WM_UPDATEOGRE          (WM_USER + 100)
#define WM_CLOSESCENE          (WM_USER + 101)
#define WM_LOADSCENE           (WM_USER + 102)
#define WM_RELOADUSERRESOURCES (WM_USER + 103)
#define CURSOR_ARROW 0
#define CURSOR_CROSS 1


//static bool ViewKeyboard[1024];

// CChildView window

class CChildView : public CWnd
{
// Construction
public:

	bool  m_OgreInitialised;
	bool  m_RenderStop;
	float m_FrameRate;

    void SetupOgre(void);
	void ProcessKeyActions();
 
    bool TerminateScene();
	void ShowCursor(BOOL bShow) {if(m_CursorHidden == bShow) {::ShowCursor(bShow);m_CursorHidden = !bShow;}};
	
	CChildView();
	virtual ~CChildView();

    // Generated message map functions
protected:
	unsigned int  m_ObjCounter;
	unsigned int  m_LastKeyEventTime;
	bool m_ScreenResize;
	int m_FrameCounter;
	double m_TotalFrameTime;
	unsigned int m_CurrentCursor;
	BOOL m_CursorHidden;

	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	virtual void eventOccurred (const Apo::String &eventName, const NameValuePairList *parameters=0)
	{
	 if(m_ScreenResize) return;
	 if(eventName == "DeviceLost") m_RenderStop = true;
	// gLogManger.outBasic("RENDERSYSTEM: " + eventName);
	};

    void OnTerminateScene();
	void OnAfterLoadScene();
    void OnUpdate(float time) {};
	void DisplayFPS(float time);
	//void AdjustUserResourceDirectories(String oldpath);
    unsigned int GetMouseButtons(unsigned int flags);
	
	afx_msg void OnPaint();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnMButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
	afx_msg void OnMouseLeave();

	afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
	afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
    afx_msg void OnSetFocus(CWnd* pOldWnd);
	afx_msg void OnKillFocus(CWnd* pNewWnd);

	afx_msg LRESULT OnUpdateOgre(WPARAM wParam, LPARAM lParam); 
    afx_msg LRESULT ReloadUserResources(WPARAM wParam, LPARAM lParam); 
	DECLARE_MESSAGE_MAP()
};

